package weixin

import (
	"gitcode.com/G-YT/iHealth25/server/plugin/weixin/global"
	"gitcode.com/G-YT/iHealth25/server/plugin/weixin/router"
	"github.com/gin-gonic/gin"
)

type WxPayPlugin struct{}

type WeChatPlugin struct{}

func CreateWeChatPlugin(
	AppID string,
	AppSecret string,
) *WeChatPlugin {
	global.WeiXinConfig.AppID = AppID
	global.WeiXinConfig.AppSecret = AppSecret

	return &WeChatPlugin{}
}

func CreateWxPayPlug(
	MchID string,
	AppId string,
	NotifyUrl string,
	MchCertificateSerialNumber string,
	MchAPIv3Key string,
	CertPath string,
	KeyPath string,
) *WxPayPlugin {
	global.WxPayConfig.MchID = MchID
	global.WxPayConfig.AppID = AppId
	global.WxPayConfig.NotifyUrl = NotifyUrl
	global.WxPayConfig.MchCertificateSerialNumber = MchCertificateSerialNumber
	global.WxPayConfig.MchAPIv3Key = MchAPIv3Key
	global.WxPayConfig.CertPath = CertPath
	global.WxPayConfig.KeyPath = KeyPath
	return &WxPayPlugin{}
}

func (*WxPayPlugin) Register(group *gin.RouterGroup) {
	router.RouterGroupApp.InitWxPayRouter(group)
}

func (*WxPayPlugin) RouterPath() string { return "wxPay" }

func (*WeChatPlugin) Register(group *gin.RouterGroup) {
	router.RouterGroupApp.InitWeChatRouter(group)
}

func (*WeChatPlugin) RouterPath() string { return "weChat" }
